home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / userintf / menu_eg.sx next >
Encoding:
Text File  |  1996-05-21  |  1.7 KB  |  55 lines  |  [TEXT/ttxt]

  1. <<<
  2. global win := new window boundary:(new rect x2:200 y2:200) centered:true
  3.  
  4. function makeButton label -> 
  5. (
  6.     local relPres := new TextPresenter boundary: (new rect x2:100 y2:20) \
  7.                                         target:label \
  8.                                         fill:whiteBrush \
  9.                                         stroke:blackBrush
  10.     relPres.inset := new Point x:4 y:2                                   
  11.     local prsPres := new TextPresenter boundary: (new rect x2:100 y2:20) \
  12.                                         target:label \
  13.                                         fill:blackBrush \
  14.                                         stroke:blackBrush
  15.     prsPres.inset := new Point x:4 y:2                                   
  16.                                       
  17.     local button := new PushButton
  18.     button.releasedpresenter := relPres
  19.     button.pressedpresenter := prsPres
  20.     button.activateAction := (authordata self -> print label)
  21.  
  22.     return button
  23. )
  24.     
  25. -- Defined pushbuttons
  26. global menuButton := (makeButton "MAIN")
  27. global menuItem1 := (makeButton "menuItem1")
  28. global menuItem2 := (makeButton "menuItem2")
  29. global menuItem3 := (makeButton "menuItem3")
  30.  
  31. global submenuButton := (makeButton "SUBMENU")
  32. global submenuItem1 := (makeButton "submenuItem1")
  33. global submenuItem2 := (makeButton "submenuItem2")
  34. global submenuItem3 := (makeButton "submenuItem3")
  35.  
  36. -- Define menus
  37. global mainmenu := new menu placement:@menuDown
  38. append mainmenu menuItem1
  39. append mainmenu menuItem2
  40. append mainmenu menuItem3
  41. append mainmenu submenuButton
  42.  
  43. global submenu := new menu placement:@menuRight
  44. append submenu submenuItem1
  45. append submenu submenuItem2
  46. append submenu submenuItem3
  47.  
  48. submenuButton.menu := submenu
  49. menuButton.menu := mainmenu
  50.  
  51. append win menuButton
  52. show win
  53.  
  54. global ac := new ActuatorController space:win wholespace:true
  55. >>>